package com.xinyue.auto.reader.util;

import com.xinyue.auto.type.Type;

public class JavaTypeUtil implements Type{

	/**
	 * 验证是否是Java类型，返回类型的package
	 * @param type
	 * @return
	 * @throws Exception
	 */
	public static String validate(String type) throws Exception {
		//返回值
		String value = null;
		
		//是否是合法的Java类型
		boolean flag = false;
		if(STRING.equals(type)) {
			flag = true;
		}else if(INT.equals(type)) {
			flag = true;
		}else if(LONG.equals(type)) {
			flag = true;
		}else if(DATE.equals(type)) {
			value = "java.util.Date";
			flag = true;
		}else if(BOOLEAN.equals(type)) {
			flag = true;
		}else if(DOUBLE.equals(type)) {
			flag = true;
		}else if(CHAR.equals(type)) {
			flag = true;
		}else if(BYTE.equals(type)) {
			flag = true;
		}else if(SHORT.equals(type)) {
			flag = true;
		}else if(FLOAT.equals(type)) {
			flag = true;
		}else if(BIGDECIMAL.equals(type)) {
			value = "java.math.BigDecimal";
			flag = true;
		}else if(BLOB.equals(type)) {
			value = "java.sql.Blob";
			flag = true;
		}
		
		//不合法则抛出异常信息
		if(!flag) {
			throw new Exception("type属性值非法：" + type);
		}
	
		return value;
	}
}
